package com.yunfei.api.v2;

import com.yunfei.api.v2.contants.QueryHeTongSignInfoContant;
import com.yunfei.api.v2.service.AutoAddJiaGaiJobService;
import com.yunfei.bo.result.ResultModel;
import com.yunfei.enums.ResultStatus;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 系统自动加盖管理人公章
 * @Author: zhengyunfei
 * @Date: 2018/6/15
 * @time:11:26
 */
@SuppressWarnings("ALL")
@RestController
@RequestMapping("/api/v2/job/autoJiaGaiGongZhang")
@Api(value = QueryHeTongSignInfoContant.AUTO_JIAGAI_NAMESPACE,tags =  QueryHeTongSignInfoContant.AUTO_JIAGAI_NAMESPACE )
public class AutoJiaGaiApiController {

    @Autowired
    private AutoAddJiaGaiJobService autoAddJiaGaiJobService;
    /**
     * @Description: 系统自动执行，每五分钟一次
     * @Author: zhengyunfei
     * @Date: 2019/7/29
     * @time:10:30
     */
    @PostMapping(value="/run")
    @ApiOperation(position = 3,value = QueryHeTongSignInfoContant.AUTO_JIAGAI_NAMESPACE,notes = QueryHeTongSignInfoContant.AUTO_JIAGAI_NAMESPACE_NOTES,response = ResultModel.class)
    @ResponseBody
    public Object autoRun(){
        ResultModel resultModel=new ResultModel();
        try{
            autoAddJiaGaiJobService.run();
            resultModel.setData("执行成功");
            resultModel.setCode(ResultStatus.SUCCESS.getCode());
            resultModel.setMessage(ResultStatus.SUCCESS.getMessage());
        }catch (Exception e){
            resultModel.setData("执行失败");
            resultModel.setCode(ResultStatus.ERROR.getCode());
            resultModel.setMessage(ResultStatus.ERROR.getMessage());
        }

        return resultModel;
    }

}
